package com.xinyue.dz.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xinyue.dz.bean.Role;
import com.xinyue.dz.bean.User;
import com.xinyue.dz.dao.UserDao;
import com.xinyue.dz.dao.UserRoleDao;
import com.xinyue.dz.service.UserService;
import com.xinyue.dz.bean.Organization;

@Service
@Transactional
public class UserServiceImpl implements UserService{
	@Autowired
	UserDao dao;
	
	@Autowired
	UserRoleDao urdao;

	@Override
	public void save(User entity) {
		dao.save(entity);
	}

	@Override
	public Integer deleteById(int userId) {
		return dao.deleteById(userId);
	}

	@Override
	public void update(User entity) {
		dao.update(entity);
	}
	
	@Override
	public void saveOrUpdate(User entity) {
		dao.saveOrUpdate(entity);
	}

	@Override
	public User queryById(int userId) {
		return dao.queryById(userId);
	}

	@Override
	public List<User> queryAll(int begin, int count) {
		return dao.queryAll(begin, count);
	}

	@Override
	public Long queryCount() {
		return dao.queryCount();
	}
	
	@Override
	public Organization queryOrganizationByOrgId(int orgId) {
		return dao.queryOrganizationByOrgId(orgId);
	}

	@Override
	public Long queryRoleCountByUserId(int userId) {
		return urdao.queryRoleCountByUserId(userId);
	}

	@Override
	public List<Role> queryRoleByUserId(int userId, int begin, int count) {
		return urdao.queryRoleByUserId(userId, begin, count);
	};
}